import { ApiProperty } from '@nestjs/swagger';
import BaseMaterialEntity from './../base/base-material.entity';
import { Column, Entity } from 'typeorm';

@Entity({ name: 'production_order' })
export default class ProductionOrder extends BaseMaterialEntity {
  @Column({ type: 'varchar', length: 50, name: 'order_code', unique: true, comment: '工单编号' })
  @ApiProperty()
  orderCode: string;

  @Column({ type: 'varchar', length: 50, name: 'order_status_code', comment: '工单状态编号' })
  @ApiProperty()
  orderStatusCode: string;

  @Column({
    type: 'varchar',
    length: 50,
    name: 'order_status_name',
    nullable: true,
    comment: '工单状态',
  })
  @ApiProperty()
  orderStatusName: string;

  @Column({ type: 'varchar', length: 50, name: 'machine_code', comment: '设备编号' })
  @ApiProperty()
  machineCode: string;

  @Column({
    type: 'varchar',
    length: 50,
    name: 'material_remark',
    nullable: true,
    comment: '产品备注',
  })
  @ApiProperty()
  materialRemark: string;

  @Column({ type: 'float', name: 'order_num', comment: '工单数' })
  @ApiProperty()
  orderNum: number;

  @Column({ type: 'float', nullable: true, name: 'paperboard_num', comment: '纸板张数' })
  @ApiProperty()
  paperboardNum: number;

  @Column({
    type: 'datetime',
    nullable: true,
    name: 'scheduled_start_time',
    comment: '计划开工时间',
  })
  @ApiProperty()
  scheduledStartTime: Date;

  @Column({ type: 'datetime', nullable: true, name: 'scheduled_end_time', comment: '计划完工时间' })
  @ApiProperty()
  scheduledEndTime: Date;

  @Column({
    type: 'varchar',
    length: 50,
    name: 'customer_order_no',
    nullable: true,
    comment: '客户单号',
  })
  @ApiProperty()
  customerOrderNo: string;

  @Column({ type: 'datetime', nullable: true, name: 'customer_delivery_date', comment: '客户交期' })
  @ApiProperty()
  customerDeliveryDate: Date;

  @Column({ type: 'float', name: 'adjuest_num', default: 0, comment: '调机数' })
  @ApiProperty()
  adjuestNum: number;

  @Column({
    type: 'datetime',
    nullable: true,
    name: 'adjuest_success_time',
    comment: '调机成功时间',
  })
  @ApiProperty()
  adjuestSuccessTime: Date;

  @Column({
    type: 'float',
    nullable: true,
    name: 'adjuest_duration',
    comment: '调机时长',
  })
  @ApiProperty()
  adjuestDuration: number;

  @Column({ type: 'float', name: 'produced_num', default: 0, comment: '已生产数' })
  @ApiProperty()
  producedNum: number;

  @Column({ type: 'varchar', name: 'erp_no', nullable: true, comment: '第三方订单编号' })
  @ApiProperty()
  erpNo: string;

  @Column({ type: 'varchar', name: 'pro_order', nullable: true, comment: '开工顺序' })
  @ApiProperty()
  proOrder: string;

  @Column({ type: 'float', name: 'electricity_consumption', nullable: true, comment: '用电量' })
  @ApiProperty()
  electricityConsumption: number;

  @Column({ type: 'float', name: 'water_consumption', nullable: true, comment: '用水量' })
  @ApiProperty()
  waterConsumption: number;

  @Column({
    type: 'float',
    name: 'scheduled_debug_time',
    nullable: true,
    comment: '计划调机用时（min）',
  })
  @ApiProperty()
  scheduledDebugTime: number;

  @Column({
    type: 'float',
    name: 'scheduled_product_time',
    nullable: true,
    comment: '计划生产用时（min）',
  })
  @ApiProperty()
  scheduledProductTime: number;

  @Column({
    type: 'datetime',
    name: 'actual_complete_date',
    nullable: true,
    comment: '实际完工时间',
  })
  @ApiProperty()
  actualCompleteDate: Date;
}
